package com.cdream.basic.algorithm.leetcode.string;


import java.util.ArrayList;
import java.util.List;

public class Offer6 {
    public int[] reversePrint(ListNode head) {
        int count = 0;
        ListNode dummy = head;
        while (dummy!=null){
            count++;
            dummy = dummy.next;
        }
        int[] ints = new int[count];
        for (int i = ints.length - 1; i >= 0; i--) {
           ints[i] = head.val;
           head = head.next;
        }
        return ints;

    }
}
class ListNode {
    int val;
    ListNode next;

    ListNode(int x) {
        val = x;
        next = null;
    }
}
